package com.szjlc.responsebodyadvice.service.impl;

import com.szjlc.responsebodyadvice.dao.EmployeeDao;
import com.szjlc.responsebodyadvice.entity.Employee;
import com.szjlc.responsebodyadvice.service.EmployeeService;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;

/**
 * 雇员表(Employee)表服务实现类
 * @author makejava
 * @since 2022-11-19 14:35:47
 */
@Service("employeeService")
public class EmployeeServiceImpl implements EmployeeService {
    @Resource
    private EmployeeDao employeeDao;

    /**
     * 通过ID查询单条数据
     * @param empId 主键
     * @return 实例对象
     */
    @Override
    public Employee findById(Long empId) {
        return this.employeeDao.findById(empId);
    }

    /**
     * 查询多条数据
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<Employee> queryAllByLimit(int offset, int limit) {
        return this.employeeDao.queryAllByLimit(offset, limit);
    }

    /**
     * 查询所有
     * @return 对象列表
     */
    @Override
    public List<Employee> findAll() {
        return this.employeeDao.findAll();
    }

    /**
     * 新增数据
     * @param employee 实例对象
     * @return 实例对象
     */
    @Override
    public Employee save(Employee employee) {
        this.employeeDao.insert(employee);
        return employee;
    }

    /**
     * 修改数据
     * @param employee 实例对象
     * @return 实例对象
     */
    @Override
    public Employee update(Employee employee) {
        this.employeeDao.update(employee);
        return this.findById(employee.getEmpId());
    }

    /**
     * 通过主键删除数据
     * @param empId 主键
     * @return 是否成功
     */
    @Override
    public void deleteById(Long empId) {
        this.employeeDao.deleteById(empId);
    }
}
